import React, { Component } from 'react'
import GlobalBorder from '@c/globalBorder'
import Ctable from '@c/table'
import Btns from '@c/table-btns'
import { connect } from 'dva'

@connect(s => ({
  loading: s.loading.models['company'],
  ...s['company']
}))
class Page extends Component {
  constructor(props) {
    super(props)
    this.columns = [
      {
        title: '零件所属公司',
        dataIndex: 'companyName',
      },
      {
        title: '工序数量',
        dataIndex: 'processNumber',
        align: 'center',
        width: 120,
      },
      {
        title: '最后编辑时间',
        dataIndex: 'updateTime',
        align: 'center',
        width: 200,
      },
      {
        title: '最后编辑人',
        dataIndex: 'modifierName',
        align: 'center',
        width: 150,
      },
      {
        title: '操作',
        align: 'center',
        width: 80,
        render: (val) => {
          const btns=[
            {
              name: '编辑',
              click: () => this.onEdit(val),
            },
          ]
          return(
            <Btns btns={btns}/>
          )
        }
      }
    ]
  }
  // componentDidMount() {}
  onEdit=(val) => {
    this.props.dispatch({
      type: 'company/onEdit',
      val
    })
  }
  // 渲染表格试图组件
  renderTable = () => {
    return (
      <Ctable
        url={'/companyProcess/queryCompanyPage'}
        columns={this.columns}
      />
    )
  }
  render() {
    return (
      <GlobalBorder>
        {this.renderTable()}
      </GlobalBorder>
    )
  }
}

export default Page
